﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BugBug.Access;

namespace BugBug.Business
{
    public class BugBusiness : BusinessBase
    {
        public static List<Bug> GetBugs()
        {
            return Entity.Bugs.ToList();
        }

        public static Bug GetBug(Int64 bugId)
        {
            var query= from b in Entity.Bugs where b.ID==bugId select b;
            return query.First<Bug>();
        }

        public static void UpdateBug(Bug bug)
        {           
            var query = from b in Entity.Bugs where b.ID == bug.ID select b;
            Bug b2 = query.First<Bug>();
            b2.Categories = bug.Categories;
            b2.Last_Updated_Date = bug.Last_Updated_Date;
            b2.Priorities = bug.Priorities;
            b2.Reported_Date = bug.Reported_Date;
            b2.Reported_User = bug.Reported_User;

            Entity.SaveChanges();
        }
    }
}
